package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.*;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.query.StrategyQueryObject;
import cn.wolfcode.trip.base.service.*;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("strategies")
public class StrategyController {
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    @Autowired
    private IStrategyDetailService strategyDetailService;
    @Autowired
    private ITagService tagService;

    @Autowired
    private IStrategyCommentService strategyCommentService;

    /**
     * 获取所有推荐大攻略
     *
     * @param qo
     * @return
     */
    @RequestMapping(method = RequestMethod.GET)
    public PageInfo query(StrategyQueryObject qo) {
        return strategyService.queryForList(qo);
    }

    /**
     * 根据id查询大攻略信息
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public Strategy getById(@PathVariable Long id) {
        return strategyService.getById(id);
    }

    /**
     * 根据id查询攻略分类信息
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/{id}/catalogs", method = RequestMethod.GET)
    public List<StrategyCatalog> getCatalogByStrategyId(@PathVariable Long id) {
        return strategyCatalogService.listByStrategyId(id);
    }

    @RequestMapping(value = "/details/{id}", method = RequestMethod.GET)
    public StrategyDetail getByDetailId(@PathVariable Long id) {
        return strategyDetailService.getByDetailId(id);
    }


    //根据id获取全部的裸游标签  只要十条
    @RequestMapping(value = "/tags", method = RequestMethod.GET)
    public List<Tag> getListTags() {
        return tagService.getListTags();
    }

    // 获取全部的分类数据渲染到页面  也秒实现分页效果
    @RequestMapping(value = "/comments", method = RequestMethod.GET)
    public PageInfo<StrategyComment> getListStrategycomment(QueryObject qo) {
        return strategyCommentService.getListStrategyComment(qo);
    }
    // 获取全部的分类数据渲染到页面  也秒实现分页效果
    @RequestMapping(value = "/comments/{id}", method = RequestMethod.GET)
    public StrategyComment getStrategycomment(@PathVariable  Long id) {
        return strategyCommentService.getStrategyComment(id);
    }
}
